﻿$(function () {

    var getUrl = function (url) {
        var baseUrl = $("#baseUrl").val();
        return baseUrl + url;
    };

    

    $("#button1").click(function (e) {
        var url = getUrl($("#url1").val());
        $.get(url, function (result) {
            $("#result1").html(JSON.stringify(result));

            var template = $("#template1");
            var array = result.data;

            var container = $("#htmlResult1");
            container.empty();
            
            for (var i = 0; i < array.length; i++) {
                console.log(array[i].avatar);
                var clone = template.clone();
                clone.find(".media-object").attr("src", array[i].avatar);
                clone.find(".media-heading")
                    .html(array[i].first_name.toUpperCase() + " " + array[i].last_name.toUpperCase());
                container.append(clone);
                clone.show(500);

            }

        });
    });


});